package ldzy.soft1;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class Servlet2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("servlet2");
//        第一步：用this对象来获取ServletContext对象
        ServletContext context=this.getServletContext();
//        第二步：用ServletContext对象的getInitParameter方法来获取对应的参数值
        String companyName=context.getInitParameter("companyName");
        //        封装成一个响应消息
//        第一步：在response参数中提取一个PrintWrite对象
        PrintWriter out= response.getWriter();
//        第二步：用PrintWrite对象的write方法，往浏览器输出内容
        out.write(companyName);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
